SET QUOTED_IDENTIFIER ON
GO
SET ANSI_NULLS ON
GO
-- =============================================
-- Author:		Paulo Fournier
-- Create date: 2013-01-27
-- Description:	Define o patrocinio
-- =============================================
CREATE PROCEDURE ext.setPatrocinio
	-- Add the parameters for the stored procedure here
	@nome VARCHAR(20), 
	@foto VARBINARY(MAX)
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

    -- Insert statements for procedure here
	IF(EXISTS(SELECT TOP 1 1 FROM ext.Patrocinios))
	BEGIN
		UPDATE ext.Patrocinios SET Nome = @nome, Foto = @foto;
	END
	ELSE
	BEGIN
		INSERT INTO ext.Patrocinios ( Nome, Foto )
		VALUES  ( @nome,  @foto )
	END
	
END
GO
